package com.edison.demo.controller;

import com.edison.demo.biz.DataBatchManager;
import com.edison.demo.common.ApiResponse;
import com.edison.demo.dto.BatchDataGenerateDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutionException;

/**
 * @author edison
 */
@RestController
@RequestMapping("data-generator")
public class DataGeneratorController {


    private final DataBatchManager dataBatchManager;
    @Autowired
    public DataGeneratorController(DataBatchManager dataBatchManager) {
        this.dataBatchManager = dataBatchManager;
    }


    @PostMapping("/consumer-base-info")
    public ApiResponse<String> genConsumerBaseInfo(@RequestBody BatchDataGenerateDTO batchDataGenerateDTO) throws ExecutionException, InterruptedException {
        return ApiResponse.success(dataBatchManager.generateConsumerBaseInfo(batchDataGenerateDTO).get() + " records was updated");
    }

    @PostMapping("/customer-personal-basic-info")
    public ApiResponse<String> genCustomerPersonalBasicInfo(@RequestBody BatchDataGenerateDTO batchDataGenerateDTO) throws ExecutionException, InterruptedException {
        return ApiResponse.success(dataBatchManager.generateCustomerPersonalBasicInfo(batchDataGenerateDTO).get() + " records was updated");
    }
}
